<template>
	<view class="mainbgc" v-if="pageshow">
		<view class="content">
			<view class="center">
				<view class="flexbetween flex_wrap">
					<view class="flexleft">
						<view class="image_ya">
							<image :src="dataAll.user.avatar_text" mode=""></image>
						</view>
						<view class="center_zi ">
							<view class="word_hei">{{dataAll.user.nickname}}</view>
							<view class="hui time">{{dataAll.createtime_text}}</view>
						</view>
					</view>
					<view class="flexleft">
						<view class="bluer">{{dataAll.xz}}</view>
					</view>
				</view>
				<!-- l类型 -->
				<view class="flexleft flex_wrap">
					<view class="leixing margin_top" v-for="item in dataAll.flags" :key="item">{{item}}</view>
				</view>
			</view>
			<!-- 求职意向 -->
			<view class="center_nav">
				<view class="text_weight" style="font-size: 32rpx;">求职意向</view>
				<!-- <view class="word_zi quizhi">工作性质：全职</view> -->
				<view class="text_weight margin_top">期望行业：{{dataAll.hy.name || ""}}</view>
				<view class="text_weight margin_top">期望职位：{{dataAll.zw || ""}}</view>
				<view class="text_weight margin_top">工作地区：{{dataAll.cityinfo || ""}}</view>
				<view class="text_weight margin_top">期望薪资：{{dataAll.xz || ""}}</view>
			</view>
			<!-- 新增 -->
			<view class="center_nav">
				<view class="text_weight" style="font-size: 32rpx;">个人简历</view>
				<view class="word_zi margin_top">工作年限：{{dataAll.jy || ""}}</view>
				<view class="word_zi">职称：{{dataAll.zc || ""}}</view>
				<view class="word_zi">兴趣爱好：{{dataAll.xqah || ""}}</view>
				<view class="word_zi">专业特长：{{dataAll.zytc || ""}}</view>
				<view class="word_zi">电话：{{dataAll.mobile || ""}}</view>
				<view class="word_zi">座机：{{dataAll.zj || ""}}</view>
				<view class="word_zi">邮箱：{{dataAll.email || ""}}</view>
			</view>
			<view class="center_nav" v-if="dataAll.images_text.length">
				<view class="text_weight province_jiangsu">证件照</view>
				<view class="flexleft margin_top flex_wrap">
					<view class="item_image_box flexcenter" v-for="(ite,index) in dataAll.images_text" :key="ite" @click="previewimg(index,dataAll.images_text)">
						<view class="item_image margin_top">
							<image :src="ite" mode=""></image>
						</view>
					</view>
				</view>
			</view>

			<!-- 新增结束 -->
			<!-- 上传个人简历 -->
			<view class="center_nav flexbetween" v-if="dataAll.files">
				<view class="flexleft">
					<view class="resume"></view>
					<view class="uploading">已上传个人简历附件</view>
				</view>
				<view class="download" @click="downloadFun">立即下载</view>
			</view>
			<!-- 求职描述 -->
			<view class="center_nav">
				<view class="text_weight ">求职描述</view>
				<view class="word_zi quizhi">{{dataAll.des}}</view>
			</view>
		</view>
		<!-- footer -->
		<view class="footer flexbetween">
			<view class="flexleft">
				<view class="" @click="shareadd">
					<button open-type="share" class="footer_stars">
						<view class="share"></view>
						<view class=" share_zi">分享</view>
					</button>
				</view>
				<view class="footer_star" @click="collect">
					<!-- 已收藏 图片-->
					<view class="collect_star flexcolumn" v-show="dataAll.is_collect"></view>
					<view class="star flexcolumn " v-show="!dataAll.is_collect"></view>
					<view class="collect">收藏</view>
				</view>
			</view>
			<view class="flexleft footer_right" @click="phone(dataAll.mobile)">
				<view class="phones">拨打电话</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				dataAll: {},
				is_login: true,
				pageshow: false
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.getdetail()
		},
		onShow() {
			let _this = this
			if (!httpRequest.checkIsLogin()) {
				_this.is_login = false
			}
		},
		methods: {
			previewimg(index, arr) {
				let i = arr; //获取当前页面的轮播图数据
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			// 下载附件
			downloadFun(enclosure) {
				var that = this
				//加载框动画
				uni.showLoading({
					title: '正在下载……'
				});
				uni.downloadFile({
					url: that.dataAll.files, //下载地址接口返回
					success: (data) => {
						if (data.statusCode === 200) {
							//隐藏加载框
							uni.hideLoading();
							//文件保存到本地
							uni.saveFile({
								tempFilePath: data.tempFilePath, //临时路径
								success: function(res) {
									uni.showToast({
										icon: 'success',
										mask: true,
										// title: '文件已保存：' + res.savedFilePath, //保存路径
										title: '下载成功',
										duration: 2000,
									});
									//自动打开文档查看
									setTimeout(() => {
										var filePath = res.savedFilePath;
										uni.openDocument({ //新开页面打开文档，支持格式：doc, xls, ppt, pdf, docx, xlsx, pptx。
											filePath: filePath,
											showMenu: true,
											success: function(res) {}
										});
									}, 2000)
								}
							});
						}
					},
					fail: (err) => {
						console.log(err);
						uni.showToast({
							icon: 'none',
							mask: true,
							title: '文件下载失败',
						});
					},
				});
			},
			zhiwie(id) {
				uni.navigateTo({
					url: '/pages/index/zhaopingrxq?id=' + id
				})
			},
			shareadd() {
				httpRequest.request('/api/zp/addZpShareNum', 'GET', {
					id: this.listid,
				}, false, false, true).then(res => {})
			},
			onShareAppMessage() {
				return {
					title: this.dataAll.title,
					path: "pages/index/zhiweixiangqing?id=" + this.listid + "&invite_code=" + uni.getStorageSync(
						"invite_code"),
				}
			},
			collect() {
				httpRequest.request('/api/zp/addZpCollect', 'GET', {
					id: this.listid,
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.getdetail()
					}
				})
			},
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {})
			},
			getdetail() {
				httpRequest.request('/api/zp/detail', 'GET', {
					id: this.listid || 3
				}, false, false, true).then(res => {
					this.pageshow = true
					if (res.code == 1) {
						this.dataAll = res.data
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			kmUnit(m) {
				var v;
				if (typeof m === 'number' && !isNaN(m)) {
					if (m >= 1000) {
						v = (m / 1000).toFixed(2) + 'km'
					} else {
						v = m + 'm'
					}
				} else {
					v = '0m'
				}
				return v;
			},
			openmap() {
				uni.openLocation({
					latitude: Number(this.dataAll.shop_apply.latitude), //即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
					longitude: Number(this.dataAll.shop_apply.longitude), //即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
					name: this.dataAll.shop_apply.shop_name, //即将传到高德或腾讯地图的店铺名称
					address: this.dataAll.shop_apply.cityinfo + this.dataAll.shop_apply.address, //即将传到高德或腾讯地图的详细地址
					scale: 18
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.image_ya {
		width: 77rpx;
		height: 77rpx;
		border-radius: 50%;

		image {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
	}

	.item_image_box {
		width: 25%;
	}

	.item_image {
		width: 144rpx;
		height: 144rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.blue {
		font-size: 28rpx;
		font-weight: 500;
		color: #228DFF;
	}

	.content {
		padding: 30rpx 27rpx 200rpx 27rpx;
	}

	.center {
		padding-bottom: 30rpx;
		background-color: #fff;
		padding: 30rpx 30rpx;
	}

	.center_nav {
		margin-top: 30rpx;
		padding-bottom: 30rpx;
		background-color: #fff;
		padding: 30rpx 30rpx;
	}

	.leixing {
		background: RGBA(233, 244, 255, 1);
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #228DFF;
		padding: 4rpx 33rpx 4rpx 34rpx;
		margin-right: 12rpx;
	}

	.bluer {
		font-size: 28rpx;
		font-weight: 500;
		color: #228DFF;
	}

	.lx {
		padding: 30rpx 0rpx 20rpx 0rpx;
	}

	.center_zi {
		padding: 0rpx 20rpx;
	}

	.quizhi {
		padding-top: 30rpx;
	}

	.word_zi {
		margin-bottom: 10rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #383838;
		line-height: 50rpx;
	}

	.uploading {
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		padding-left: 31rpx;
	}

	.download {
		border-radius: 38rpx 38rpx 38rpx 38rpx;
		opacity: 1;
		border: 2rpx solid #228DFF;
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #228DFF;
		padding: 10rpx 30rpx;
	}

	.footer_stars {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}

	.footer_star {
		padding-left: 66rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}

	.footer {
		width: 100%;
		box-sizing: border-box;
		position: fixed;
		bottom: 0rpx;
		background-color: #fff;
		padding: 30rpx 46rpx;
		padding-bottom: 57rpx;
	}

	.phones {
		background: #228DFF;
		border-radius: 13rpx 13rpx 13rpx 13rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
		padding: 21rpx 42rpx 21rpx 43rpx;
	}

	.collect {
		margin-top: 13rpx;
	}

	.share_zi {
		margin-top: 13rpx;
	}

	.time {
		padding-top: 5rpx;
	}
</style>